package com.syj.collect.model;

import android.annotation.TargetApi;
import android.os.Build;
import android.os.Bundle;

import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.syj.collect.Present.CollectPresent;
import com.syj.collect.adapter.MyCollectAdapter;
import com.syj.collect.app.R;
import com.syj.collect.base.BaseMvpAvtivity;
import com.syj.collect.base.EmptyRecyclerView;
import com.syj.collect.entry.MyCollectBean;
import com.syj.collect.view.CollectActivityView;

import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

public class MyCollectActivity extends BaseMvpAvtivity<CollectActivityView, CollectPresent> implements CollectActivityView {
    @BindView(R.id.com_rerec)
    EmptyRecyclerView collectRcl;

    @Override
    public CollectPresent initPresenter() {
        return new CollectPresent();
    }

    @TargetApi(Build.VERSION_CODES.LOLLIPOP)
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_collect);
        ButterKnife.bind(this);
        initTitle("我的收藏");
        initView();
        //presenter. 网络求数据
        loadingDialog.create();
        loadingDialog.create();
        presenter.getCollectList();
    }

    private MyCollectAdapter myCollectAdapter;

    public void initView() {
        collectRcl.setLayoutManager(new LinearLayoutManager(MyCollectActivity.this));
        collectRcl.setEmptyView(findViewById(R.id.empty_view_));
        myCollectAdapter = new MyCollectAdapter();
        collectRcl.setAdapter(myCollectAdapter);
    }

    @Override
    public void initSuccess(List<MyCollectBean.DataDTO.ListDTO> str) {
        loadingDialog.dismiss();
        myCollectAdapter.upDate(str);

    }

    @Override
    public void initFail(String str) {
        loadingDialog.dismiss();
    }
}
